package com.itcam.list_.collection_.list_;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * Author:Cammy.Wu
 * Date:2024-06-02
 * Description:
 */

public class ListDemo02 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("abc");
        list.add("def");
        list.add("ghi");
        list.add("jkl");

        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println("s = " + s);
        }

        System.out.println("-------------------------------");

        ListIterator<String> it = list.listIterator();
        while (it.hasNext()) {
            String s = it.next();
            System.out.println("s = " + s);
        }

        System.out.println("-------------------------------");

        while (it.hasPrevious()) {
            String s = it.previous();
            System.out.println("s = " + s);
        }
    }
}
